package com.mifengkong.kotlincommon

import android.util.TypedValue
import com.mifengkong.frtools.app.FRApplication

/**
 * Created by jack on 2018/5/31
 */


//判断状态是否为1
fun Int.isStatusSuccess(): Boolean = this == 1

fun String?.isStatusSuccess(): Boolean = !this.isNullable() && this == "1"

//dp
fun Int.dp(): Int = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, this.toFloat()
        , FRApplication.getInstance().resources.displayMetrics).toInt()

//判断字符串是否为空
fun String?.isNullable() = this == null || length == 0

//将任何类型转成string
fun Any?.string(): String = toString()